package com.miao.test.support;

import cn.hutool.core.util.NumberUtil;
import lombok.Data;


/**
 * @Auther: miaoguoxin
 * @Date: 2021/5/17 16:26
 * @Description:
 */
@Data
public class MetricsStatistics {
    /**开始执行的时间戳*/
    private long beginTimestamp;
    /**最后一次业务的时间戳*/
    private long endTimestamp;
    /**请求数*/
    private long requestNum;

    private long maxRt;
    private long minRt;
    private double avgRt;

    /**
     * 总的耗时时间
     * @author miaoguoxin
     * @date 2021/5/29
     */
    public long getTotalConsumeTime() {
        return this.endTimestamp - this.beginTimestamp;
    }

    public double getQps() {
        long totalConsumeTime = this.getTotalConsumeTime();
        double consumeSecond = NumberUtil.div(totalConsumeTime, 1000);
        return NumberUtil.div(this.requestNum, consumeSecond);
    }
}
